<?php
$this->breadcrumbs = array(
    'Sites' => array('/Cms/admin/site/admin'),
    'Manage Languages of ' . Site::getSiteNameById($model->site_id),
);

$this->menu = array(
    array('label' => 'Create Language', 'url' => array('create', 'siteId' => $model->site_id)),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('language-grid', {
		data: $(this).serialize()
	});
	return false;
});
");

$script = "
jQuery('#language-grid a#change-status').live('click',function() {
    jQuery.fn.yiiGridView.update('language-grid', {
        url:jQuery(this).attr('href'),
        success:function() {
            jQuery.fn.yiiGridView.update('language-grid');
        }
    });
    return false;
});";
Yii::app()->clientScript->registerScript(__CLASS__ . '#ChangeStatus', $script, CClientScript::POS_READY);
?>

<h1>Manage Languages Of <?php echo Site::getSiteNameById($model->site_id); ?> Site</h1>

<!--<p>
    You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>
    &lt;&gt;</b>
    or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>-->

<?php //echo CHtml::link('Advanced Search', '#', array('class' => 'search-button')); ?>
<!--<div class="search-form" style="display:none">
    <?php /*$this->renderPartial('_search', array(
    'model' => $model,
)); */?>
</div>--><!-- search-form -->

<?php $grid = $this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'language-grid',
    'dataProvider' => $model->search(),
    'filter' => $model,
    'selectableRows' => 2,
    'selectionChanged' => "updateSelectors",
    'columns' => array(
        array(
            'class' => 'CCheckBoxColumn',
            'value' => '$data->id',
            'htmlOptions' => array('width' => '3%'),
        ),
        //'id',
        /*'site_id',*/
        /*'locale_id',*/
        array(
            'name' => 'locale_id',
            'value' => '$data->languageName',
        ),
        array(
            'name' => 'status',
            'type' => 'raw',
            'value' => 'CHtml::link($data->statusText, array("status", "ids[]"=>$data->id, "value"=>$data->status ? \'N\' : \'Y\'), array("class"=>($data->status=="Y" ? "active" : ""),"id"=>"change-status"))',
            'filter' => $model->getStatusOptions(),
            'htmlOptions' => array(
                'class' => 'status-column',
            )
        ),
        array(
            'class' => 'CButtonColumn',
            'template' => '{delete}'
        ),
    ),
));

if ($grid->dataProvider->ItemCount) {
    $this->menu[] = array('label' => 'Delete selected items', 'url' => $this->createUrl('delete'), 'linkOptions' => array('onclick' => 'return multipleDelete("language-grid",this.href)'));
}
$this->menu[] = array('label' => 'View all sites', 'url' => array('/Cms/admin/site/admin'));

Yii::app()->clientScript->registerScriptFile(Yii::app()->core->AssetUrl . '/scripts/gridview.js', CClientScript::POS_BEGIN);
?>